package com.sihai.ehr.model.biz;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.sihai.core.BaseEntity;
import com.sihai.ehr.model.sys.Organization;
import com.sihai.ehr.model.sys.SalaryLinkedEnum;

/**
 * 社会保险管理
 * 
 * @author henry
 * 
 */
@Entity
public class SalarySocialInsurance extends BaseEntity<Long> {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2454575419219322501L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	/** 组织结构ID */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "organization_id")
	private Organization organization;

	/** 社会方案名称 */
	private String title;

	/** 养老保险缴费基数类型 */
	private SalaryLinkedEnum oldageInsuranceBaseType;
	/** 养老保险缴费基数 */
	private Float oldageBase;

	/** 工伤保险金基数类型 */
	private SalaryLinkedEnum injuryInsuranceBaseType;
	/** 工伤保险金基数 */
	private Float injuryBase;

	/** 失业保险缴费基数类型 */
	private SalaryLinkedEnum unemploymentInsuranceBaseType;
	/** 失业保险缴费基数 */
	private Float unemploymentBase;

	/** 生育保险缴费基数类型 */
	private SalaryLinkedEnum birthInsuranceBaseType;
	/** 生育保险缴费基数 */
	private Float birthBase;

	/** 医疗社保缴费基数类型 */
	@Enumerated(EnumType.STRING)
	private SalaryLinkedEnum medicalInsuranceBaseType;
	/** 医疗社保缴费基数 */
	private Float medicalInsuranceBase;

	/** 住房公积金基数类型 */
	@Enumerated(EnumType.STRING)
	private SalaryLinkedEnum fundBaseType;
	/** 住房公积金基数 */
	private Float fundBase;

	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "socialInsurance")
	private Set<SalarySocialInsuranceDetail> details = new HashSet<SalarySocialInsuranceDetail>();

	@Override
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public SalaryLinkedEnum getOldageInsuranceBaseType() {
		return oldageInsuranceBaseType;
	}

	public void setOldageInsuranceBaseType(
			SalaryLinkedEnum oldageInsuranceBaseType) {
		this.oldageInsuranceBaseType = oldageInsuranceBaseType;
	}

	public Float getOldageBase() {
		return oldageBase;
	}

	public void setOldageBase(Float oldageBase) {
		this.oldageBase = oldageBase;
	}

	public SalaryLinkedEnum getInjuryInsuranceBaseType() {
		return injuryInsuranceBaseType;
	}
	
	public void setInjuryInsuranceBaseType(
			SalaryLinkedEnum injuryInsuranceBaseType) {
		this.injuryInsuranceBaseType = injuryInsuranceBaseType;
	}

	public Float getInjuryBase() {
		return injuryBase;
	}

	public void setInjuryBase(Float injuryBase) {
		this.injuryBase = injuryBase;
	}

	public SalaryLinkedEnum getUnemploymentInsuranceBaseType() {
		return unemploymentInsuranceBaseType;
	}

	public void setUnemploymentInsuranceBaseType(
			SalaryLinkedEnum unemploymentInsuranceBaseType) {
		this.unemploymentInsuranceBaseType = unemploymentInsuranceBaseType;
	}

	public Float getUnemploymentBase() {
		return unemploymentBase;
	}

	public void setUnemploymentBase(Float unemploymentBase) {
		this.unemploymentBase = unemploymentBase;
	}

	public SalaryLinkedEnum getBirthInsuranceBaseType() {
		return birthInsuranceBaseType;
	}

	public void setBirthInsuranceBaseType(
			SalaryLinkedEnum birthInsuranceBaseType) {
		this.birthInsuranceBaseType = birthInsuranceBaseType;
	}

	public Float getBirthBase() {
		return birthBase;
	}

	public void setBirthBase(Float birthBase) {
		this.birthBase = birthBase;
	}

	public SalaryLinkedEnum getMedicalInsuranceBaseType() {
		return medicalInsuranceBaseType;
	}

	public void setMedicalInsuranceBaseType(
			SalaryLinkedEnum medicalInsuranceBaseType) {
		this.medicalInsuranceBaseType = medicalInsuranceBaseType;
	}

	public Float getMedicalInsuranceBase() {
		return medicalInsuranceBase;
	}

	public void setMedicalInsuranceBase(Float medicalInsuranceBase) {
		this.medicalInsuranceBase = medicalInsuranceBase;
	}

	public SalaryLinkedEnum getFundBaseType() {
		return fundBaseType;
	}

	public void setFundBaseType(SalaryLinkedEnum fundBaseType) {
		this.fundBaseType = fundBaseType;
	}

	public Float getFundBase() {
		return fundBase;
	}

	public void setFundBase(Float fundBase) {
		this.fundBase = fundBase;
	}

	public Set<SalarySocialInsuranceDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<SalarySocialInsuranceDetail> details) {
		this.details = details;
	}

	/**
	 * 该方法用于向order中加order项
	 * 
	 * @param insuranceDetail
	 */
	public void addDetailItem(SalarySocialInsuranceDetail insuranceDetail) {
		insuranceDetail.setSocialInsurance(this); // 用关系维护端来维护关系
		this.details.add(insuranceDetail);
	}

	public SalarySocialInsurance() {
		// TODO Auto-generated constructor stub
	}

	public SalarySocialInsurance(Long id, String title) {
		this.id = id;
		this.title = title;
	}
}
